
goog.provide('secretcuz.portfolio');
goog.provide('secretcuz.portfolio.Portfolio');

goog.require('goog.dom');
goog.require('goog.net.XhrIo');
goog.require('goog.style');

secretcuz.portfolio.makePortfolio = function(container) {
	var url = 'https://spreadsheets.google.com/feeds/list/0AgPdwaRwADWMdHZlN3hQS29WZHg2TFdPNHF1eEdIRXc/1/public/basic?alt=json';
	goog.net.XhrIo.send(url, function(e) {
		var xhr = e.target;
		var obj = xhr.getResponseJson();
		var list = obj.feed.entry;
		var lLength = list.length;
		goog.dom.setTextContent(container, '');
		for (var i = 0; i < lLength; i++) {
			var value = list[i];
			var text = value.title.$t;
			var media = value.content.$t.substring(7, value.content.$t.length);
			var item = new secretcuz.portfolio.PortfolioItem(text, media);
			var node = item.getDom();
			goog.dom.appendChild(container, node);
		}
		goog.style.setStyle(goog.dom.getElement("footer"), "display", "block");
	});
};

/**
 * Portfolio item
 * @param {string} title
 * @param {string} content
 * @constructor
 */
secretcuz.portfolio.PortfolioItem = function(title, media) {
	this.title = title;
	this.media = media;
};

/**
 * Creates the DOM structure for the portfolio item
 */
secretcuz.portfolio.PortfolioItem.prototype.getDom = function() {
	var node = goog.dom.createDom('div', 'case', goog.dom.createDom('img', {'src': this.media}, null));
	return node;
};
